package com.max.sportmanage.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: sport-manage-java
 * @description:跨域处理
 * @author: max-qaq
 * @create: 2021-10-17 17:30
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry
                //允许访问的路径
                .addMapping("/**")
                //请求来源
                .allowedOrigins("http://localhost:8888")
                //允许的方法
                .allowedMethods("GET","POST","DELETE","PUT","OPTION")
                //允许携带参数
                .allowCredentials(true)
                //最大响应时间
                .maxAge(3600);
    }
}
